<template>
  <div class="fen content">
    <ul class="ul">
      <li class="li" v-for="(item, index) in this.$store.state.list" :key="index">
        <div class="bt">
          <span>{{ item.zhuti }}</span>
        </div>
        <div class="fenLe lis">
          <dl v-for="(item1, index) in item.add" :key="index">
            <dt class="dt">{{ item1.title }}</dt>
            <dd v-for="(item2, index) in item1.fen" :key="index" >
              {{ item2.title }}
            </dd>
          </dl>
          <p @click="fn(index)" class="p">展开更多</p>
        </div>
        <div class="show lis active">
          <dl v-for="(item1, index) in item.dataA" :key="index">
            <dt class="dt">{{ item1.title }}</dt>
            <dd v-for="(item2, index) in item1.fen" :key="index" @click="tiaozhuan(item2.id)">
              {{ item2.title }}
            </dd>
          </dl>
          <p @click="fn(index)" class="p">收起</p>
        </div>
        
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "Classification",

  data() {
    return {
      list: [],
      all: [], //*存完整数据
      arr: [], // * 折叠数据
      flag: true,
      title: "展开更多",
    };
  },

  mounted() {},
  created() {
    this.fn_data();
  },
  computed: {
    // title(){
    //   return this.flag?"展开更多":"展开";
    // }
  },
  methods: {
    async fn_data() {
      await this.$store.dispatch('fn_setData')
    },
    fn(index) {
      const li = document.getElementsByClassName("li")[index];
      [...li.getElementsByClassName("lis")].forEach(item => {
        item.classList.toggle('active');
      })
    },
    tiaozhuan(id){

      this.$router.push('/detail/'+id)
    }
  },
};
</script>
<style lang="less" scoped>
.ul {
  box-sizing: border-box;
  width: 100%;
  background: #f5f6f5;
  padding: 40px;
  .li {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #c7c9c9;
    &:last-child {
      border: none;
    }
  }
  div {
    span {
      font-size: 20px;
      font-weight: 700;
    }
  }
  .bt {
    float: left;
    width: 160px;
  }
  .fenLe {
    margin-left: 184px;
    overflow: hidden;
    zoom: 1;
    width: 614px;
    dl {
      float: left;
      display: inline;
      width: 180px;
      margin-left: 16px;
      border-bottom: 1px solid #f3f3f3;
      padding: 0 0 8px;
      list-style: none;
      margin-top: 2px;
      dt {
        color: #909090;
      }
      dd,
      dt {
        padding-top: 2px;
        padding-bottom: 2px;
        padding-left: 15px;
        width: 105px;
        line-height: 28px;
        
      }
      dd{
        &:hover{
          color:red;
        }
      }
    }
    p {
      float: right;
    }
  }
  .active {
    display: none;
  }
  .show {
    margin-left: 184px;
    overflow: hidden;
    zoom: 1;
    width: 614px;
    dl {
      display: block;
      margin-bottom: 16px;
      dt {
        color: #909090;
        margin-bottom: 14px;
      }
      dd,
      dt {
        padding-top: 2px;
        padding-bottom: 2px;
        padding-left: 14px;
        width: 105px;
        line-height: 28px;
      }
      dd {
        float: left;
        &:hover{
          color:red;
        }
      }
    }
  }
  .p {
    text-align: right;
  }
}
</style>